package com.xxwy.idle;

import com.xxwy.groupchat.ServerHandler;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelOption;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioChannelOption;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;

/**
 * @author wy
 * @date 2020/4/2 13:55
 */
public class Server {
  public static void main(String[] args) {
    NioEventLoopGroup bossGroup = new NioEventLoopGroup(1);
    NioEventLoopGroup workGroup = new NioEventLoopGroup();

    ServerBootstrap bootstrap = new ServerBootstrap();
    bootstrap.group(bossGroup,workGroup)
        .channel(NioServerSocketChannel.class)
        .handler(new LoggingHandler(LogLevel.INFO))
        //两种设置Keeplive风格
        .childOption(ChannelOption.SO_KEEPALIVE,true)
        .childOption(NioChannelOption.SO_KEEPALIVE,true)

        .childHandler(new ServerHandler());
  }
}
